package org.example;

public class Team {
    private Role[] roles = new Role[6];
    private int index=0;//数组下标
    //组队增加队员
    public void addMember(Role role) {// 多态应用与方法参数
        if (index >= 6) {
            System.out.println("对不起，人满了");
            return;
        }
        roles[index] = role;
        index++;
    }
    //组队成员的伤害总和
    public int attackSum(){
        int sum =0;
        for(int i=0;i< roles.length; i++){
            sum += roles[i].attack();
        }
        return sum;
    }
    public void printRole(){
        for (int i=0;i< roles.length; i++){
            System.out.println(roles[i]);
        }

    }
}
